AbstractSchool   A
last analyzed

Complexity

Total Complexity 14

Size/Duplication

Total Lines 143
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 127
dl 0
loc 143
rs 10
c 0
b 0
f 0

14 Functions

Rating   Name   Duplication   Size   Complexity  
A getEmail 0 3 1
A getNumberOfClasses 0 3 1
A getId 0 3 1
A getStatus 0 3 1
A getCreatedAt 0 3 1
A getZipCode 0 3 1
A getNumberOfStudents 0 3 1
A getReference 0 3 1
A getCity 0 3 1
A getPhoneNumber 0 3 1
A getName 0 3 1
A baseUpdate 0 25 1
A getAddress 0 3 1
A getType 0 3 1
1
import { Column, PrimaryGeneratedColumn } from 'typeorm';
2
3
export enum Status {
4
  PRIVATE = 'private',
5
  PUBLIC = 'public'
6
}
7
8
export enum Type {
9
  KINDERGARTEN = 'kindergarten',
10
  PRIMARY = 'primary',
11
  ELEMENTARY = 'elementary',
12
  MIDDLE_SCHOOL = 'middle_school',
13
  HIGH_SCHOOL = 'high_school',
14
}
15
16
export abstract class AbstractSchool {
17
  @PrimaryGeneratedColumn('uuid')
18
  protected id: string;
19
20
  @Column({ type: 'varchar', nullable: false })
21
  protected reference: string;
22
23
  @Column({ type: 'varchar', nullable: false })
24
  protected name: string;
25
26
  @Column({ type: 'varchar', nullable: false })
27
  protected address: string;
28
29
  @Column({ type: 'varchar', nullable: false })
30
  protected zipCode: string;
31
32
  @Column({ type: 'varchar', nullable: false })
33
  protected city: string;
34
35
  @Column('enum', { enum: Status, nullable: false })
36
  protected status: Status;
37
38
  @Column('enum', { enum: Type, nullable: false })
39
  protected type: Type;
40
41
  @Column({ type: 'varchar', nullable: true })
42
  protected phoneNumber: string;
43
44
  @Column({ type: 'varchar', nullable: true })
45
  protected email: string;
46
47
  @Column({ type: 'integer', nullable: true, default: 0 })
48
  protected numberOfStudents: number;
49
50
  @Column({ type: 'integer', nullable: true, default: 0 })
51
  protected numberOfClasses: number;
52
53
  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
54
  protected createdAt: number;
55
56
  constructor(
57
    reference: string,
58
    name: string,
59
    address: string,
60
    zipCode: string,
61
    city: string,
62
    status: Status,
63
    type: Type,
64
    phoneNumber?: string,
65
    email?: string,
66
    numberOfStudents?: number,
67
    numberOfClasses?: number
68
  ) {
69
    this.reference = reference;
70
    this.name = name;
71
    this.address = address;
72
    this.zipCode = zipCode;
73
    this.city = city;
74
    this.status = status;
75
    this.type = type;
76
    this.phoneNumber = phoneNumber;
77
    this.email = email;
78
    this.numberOfStudents = numberOfStudents;
79
    this.numberOfClasses = numberOfClasses;
80
  }
81
82
  public getId(): string {
83
    return this.id;
84
  }
85
86
  public getReference(): string {
87
    return this.reference;
88
  }
89
90
  public getName(): string {
91
    return this.name;
92
  }
93
94
  public getZipCode(): string {
95
    return this.zipCode;
96
  }
97
98
  public getAddress(): string {
99
    return this.address;
100
  }
101
102
  public getCity(): string {
103
    return this.city;
104
  }
105
106
  public getStatus(): Status {
107
    return this.status;
108
  }
109
110
  public getType(): Type {
111
    return this.type;
112
  }
113
114
  public getPhoneNumber(): string {
115
    return this.phoneNumber;
116
  }
117
118
  public getNumberOfStudents(): number {
119
    return this.numberOfStudents;
120
  }
121
122
  public getNumberOfClasses(): number {
123
    return this.numberOfClasses;
124
  }
125
126
  public getEmail(): string {
127
    return this.email;
128
  }
129
130
  public getCreatedAt(): number {
131
    return this.createdAt;
132
  }
133
134
  protected baseUpdate(
135
    reference: string,
136
    name: string,
137
    address: string,
138
    zipCode: string,
139
    city: string,
140
    status: Status,
141
    type: Type,
142
    email?: string,
143
    phoneNumber?: string,
144
    numberOfStudents?: number,
145
    numberOfClasses?: number
146
  ) {
147
    this.reference = reference;
148
    this.name = name;
149
    this.address = address;
150
    this.zipCode = zipCode;
151
    this.city = city;
152
    this.status = status;
153
    this.type = type;
154
    this.email = email;
155
    this.phoneNumber = phoneNumber;
156
    this.numberOfStudents = numberOfStudents;
157
    this.numberOfClasses = numberOfClasses;
158
  }
159
}
160